/*     */ package com.jcrj.action.personalOffice;
/*     */ 
/*     */ import com.jcrj.action.BaseAction;
/*     */ import com.jcrj.entity.OAddressbook;
/*     */ import com.jcrj.entity.OUser;
/*     */ import com.jcrj.service.PersonalofficeService;
/*     */ import com.jcrj.util.PoiExcelUtil;
/*     */ import java.io.IOException;
/*     */ import java.io.OutputStream;
/*     */ import java.io.PrintWriter;
/*     */ import java.net.URLDecoder;
/*     */ import java.net.URLEncoder;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
/*     */ 
/*     */ public class BookAction extends BaseAction
/*     */ {
/*     */   private List<OAddressbook> bookList;
/*     */   private PersonalofficeService personalofficeService;
/*     */   private OAddressbook book;
/*     */   private String[] ids;
/*     */   private String name;
/*     */   private String policeNumber;
/*     */   private long pageCount;
/*     */   private long totalCount;
/*     */   private Integer id;
/*     */   private List<OUser> users;
/*     */   private OUser user;
/*     */ 
/*     */   public String updateUser_book()
/*     */   {
/*     */     try
/*     */     {
/*  33 */       OUser ou = (OUser)super.getSession().get("userInfo");
/*  34 */       ou.setPhone(this.user.getPhone());
/*  35 */       ou.setTelephone(this.user.getTelephone());
/*  36 */       ou.setEmail(this.user.getEmail());
/*  37 */       this.personalofficeService.updateUserInfo(ou);
/*  38 */       super.getResponse().getWriter().write("success");
/*  39 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/*  41 */       e.printStackTrace();
/*     */       try
/*     */       {
/*  44 */         super.getResponse().getWriter().close();
/*     */       } catch (Exception e1) {
/*  46 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/*  44 */         super.getResponse().getWriter().close();
/*     */       } catch (Exception e) {
/*  46 */         e.printStackTrace();
/*     */       }
/*     */     }
/*  49 */     return null;
/*     */   }
/*     */ 
/*     */   public String updatebook() {
/*  53 */     this.user = ((OUser)super.getSession().get("userInfo"));
/*  54 */     return "success";
/*     */   }
/*     */ 
/*     */   public String deletebook() {
/*     */     try {
/*  59 */       this.personalofficeService.deletebook(this.ids);
/*  60 */       super.getResponse().getWriter().write("success");
/*  61 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/*  63 */       e.printStackTrace();
/*     */       try
/*     */       {
/*  66 */         super.getResponse().getWriter().close();
/*     */       } catch (Exception e1) {
/*  68 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/*  66 */         super.getResponse().getWriter().close();
/*     */       } catch (Exception e) {
/*  68 */         e.printStackTrace();
/*     */       }
/*     */     }
/*  71 */     return null;
/*     */   }
/*     */ 
/*     */   public String saveUser_book() {
/*     */     try {
/*  76 */       OUser ou = (OUser)super.getSession().get("userInfo");
/*  77 */       this.book.setUserId(ou.getId());
/*  78 */       this.personalofficeService.saveBookUser(this.book);
/*  79 */       super.getResponse().getWriter().write("success");
/*  80 */       super.getResponse().getWriter().flush();
/*     */     } catch (Exception e) {
/*  82 */       e.printStackTrace();
/*     */       try
/*     */       {
/*  85 */         super.getResponse().getWriter().close();
/*     */       } catch (Exception e1) {
/*  87 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/*  85 */         super.getResponse().getWriter().close();
/*     */       } catch (Exception e) {
/*  87 */         e.printStackTrace();
/*     */       }
/*     */     }
/*  90 */     return null;
/*     */   }
/*     */ 
/*     */   public String bookUser() {
/*  94 */     if ((this.id != null) && (!"".equals(this.id))) {
/*  95 */       this.book = this.personalofficeService.getbook(this.id.intValue());
/*     */     }
/*  97 */     return "success";
/*     */   }
/*     */ 
/*     */   public String bookList()
/*     */   {
/* 102 */     int count = 12;
/* 103 */     this.totalCount = this.personalofficeService.countbook(this.name, this.policeNumber).longValue();
/* 104 */     this.pageCount = ((this.totalCount - 1L) / count + 1L);
/* 105 */     if (super.getCurrentPage() > this.pageCount) {
/* 106 */       super.setCurrentPage(Long.valueOf(this.pageCount).intValue());
/*     */     }
/* 108 */     this.users = this.personalofficeService.getbookList(this.name, this.policeNumber, super.getCurrentPage(), count);
/* 109 */     return "success";
/*     */   }
/*     */ 
/*     */   public String bookUserList() {
/* 113 */     OUser ou = (OUser)super.getSession().get("userInfo");
/* 114 */     this.totalCount = this.personalofficeService.countbookUser(this.name, ou).longValue();
/* 115 */     this.pageCount = ((this.totalCount - 1L) / 10L + 1L);
/* 116 */     if (super.getCurrentPage() > this.pageCount) {
/* 117 */       super.setCurrentPage(Long.valueOf(this.pageCount).intValue());
/*     */     }
/* 119 */     this.bookList = this.personalofficeService.getbookUserList(this.name, ou, super.getCurrentPage());
/* 120 */     return "success";
/*     */   }
/*     */ 
/*     */   public String bookExcel() {
/* 124 */     OUser ou = (OUser)super.getSession().get("userInfo");
/* 125 */     OutputStream outputStream = null;
/*     */     try {
/* 127 */       String userName = URLDecoder.decode(this.name, "UTF-8");
/* 128 */       String tableName = "个人通讯录";
/* 129 */       String excelName = URLEncoder.encode(tableName, "UTF-8");
/* 130 */       super.getResponse().setHeader("Content-Disposition", "attachment; filename=" + excelName + ".xls");
/* 131 */       String[] x = { "姓名", "性别", "手机", "电话", "单位", "职业", "邮箱", "联系地址" };
/* 132 */       Object[][] data = this.personalofficeService.getbookUserList(userName, ou);
/* 133 */       HSSFWorkbook excel = PoiExcelUtil.createExcelData(tableName, x, data);
/* 134 */       outputStream = super.getResponse().getOutputStream();
/*     */ 
/* 136 */       excel.write(outputStream);
/* 137 */       outputStream.flush();
/*     */     } catch (Exception e) {
/* 139 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 142 */         if (outputStream != null) outputStream.close(); 
/*     */       }
/*     */       catch (IOException e1) {
/* 144 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 142 */         if (outputStream != null) outputStream.close(); 
/*     */       }
/*     */       catch (IOException e) {
/* 144 */         e.printStackTrace();
/*     */       }
/*     */     }
/* 147 */     return null;
/*     */   }
/*     */ 
/*     */   public List<OAddressbook> getBookList() {
/* 151 */     return this.bookList;
/*     */   }
/*     */ 
/*     */   public void setBookList(List<OAddressbook> bookList) {
/* 155 */     this.bookList = bookList;
/*     */   }
/*     */ 
/*     */   public PersonalofficeService getPersonalofficeService() {
/* 159 */     return this.personalofficeService;
/*     */   }
/*     */ 
/*     */   public void setPersonalofficeService(PersonalofficeService personalofficeService)
/*     */   {
/* 164 */     this.personalofficeService = personalofficeService;
/*     */   }
/*     */ 
/*     */   public OAddressbook getBook() {
/* 168 */     return this.book;
/*     */   }
/*     */ 
/*     */   public void setBook(OAddressbook book) {
/* 172 */     this.book = book;
/*     */   }
/*     */ 
/*     */   public String[] getIds() {
/* 176 */     return this.ids;
/*     */   }
/*     */ 
/*     */   public void setIds(String[] ids) {
/* 180 */     this.ids = ids;
/*     */   }
/*     */ 
/*     */   public String getName() {
/* 184 */     return this.name;
/*     */   }
/*     */ 
/*     */   public void setName(String name) {
/* 188 */     this.name = name;
/*     */   }
/*     */ 
/*     */   public long getTotalCount() {
/* 192 */     return this.totalCount;
/*     */   }
/*     */ 
/*     */   public void setTotalCount(long totalCount) {
/* 196 */     this.totalCount = totalCount;
/*     */   }
/*     */ 
/*     */   public long getPageCount() {
/* 200 */     return this.pageCount;
/*     */   }
/*     */ 
/*     */   public void setPageCount(long pageCount) {
/* 204 */     this.pageCount = pageCount;
/*     */   }
/*     */ 
/*     */   public Integer getId() {
/* 208 */     return this.id;
/*     */   }
/*     */ 
/*     */   public void setId(Integer id) {
/* 212 */     this.id = id;
/*     */   }
/*     */ 
/*     */   public List<OUser> getUsers() {
/* 216 */     return this.users;
/*     */   }
/*     */ 
/*     */   public void setUsers(List<OUser> users) {
/* 220 */     this.users = users;
/*     */   }
/*     */ 
/*     */   public OUser getUser() {
/* 224 */     return this.user;
/*     */   }
/*     */ 
/*     */   public void setUser(OUser user) {
/* 228 */     this.user = user;
/*     */   }
/*     */ 
/*     */   public String getPoliceNumber() {
/* 232 */     return this.policeNumber;
/*     */   }
/*     */ 
/*     */   public void setPoliceNumber(String policeNumber) {
/* 236 */     this.policeNumber = policeNumber;
/*     */   }
/*     */ }

/* Location:           /Volumes/work/oa/WEB-INF/classes/
 * Qualified Name:     com.jcrj.action.personalOffice.BookAction
 * JD-Core Version:    0.6.0
 */